GBML manual / Screen

screen_fade

Fades the whole picture into one color over so many frames and keeps it that color, without changing room: screen_fade(COLOR_BLACK, 30) darkens the screen in half a second. Use screen_fade_in to bring the picture back. Good for a cutscene, a death or the end of a level.

Works differently on Game Boy - The Game Boy has 4 shades, so a screen fade moves every shade toward the shade closest to the color: black and white fade exactly, any other color fades to its grey.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

screen_fade(color, frames)

Arguments

NameType
colorshape_color
framesint

Returns

Nothing.

Description

Fades the whole picture into one color over so many frames and keeps it that color, without changing room. screen_fade(COLOR_BLACK, 30) darkens the screen in half a second. Use screen_fade_in to bring the picture back.

The room transitions (fade_to_black and friends) only run while one room is swapped for another. screen_fade does the same fade by itself: for a cutscene, a death, or the end of a level.

Example

if (btn_pressed(BTN_START)) {
    screen_fade(COLOR_BLACK, 30);
}

Pressing START fades the picture to black over half a second, and it stays black.

The small print

Cost

One palette fade a frame while it moves, and nothing when it is still.

On the GBA

It is the same fade a room transition draws, so it shades the backgrounds and the sprites together; 60 frames is about a second. frames of 0 or less makes the color appear at once. The screen stays that color until screen_fade_in (or a room change that fades) - the game keeps running behind it, so stop the player yourself if the picture should wait. Starting a new fade while one is moving carries on from the level the screen is at now, so nothing snaps. While it moves, one small job runs every frame; once the screen has arrived it costs nothing. A game that never calls it carries none of this. A room transition, or an overlay effect with a brightness track, uses the same fade, so whichever one wrote last wins.

See also: screen_fade_inscreen_flashroom_change_extoverlay_start